package com.naughty.userlogin02.controller;

import com.alibaba.fastjson.JSON;
import com.naughty.userlogin02.bean.User;
import com.naughty.userlogin02.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class LoginController {
    @Autowired
    UserDao userDao;

//    @CrossOrigin
//    @RequestMapping("/login")
//    public String userLogin(@RequestBody User user, HttpSession session) {
//        System.out.println("User : " + user);
//        String str = "error";
//        int count = userDao.getUserByMassage(user.getUsername(), user.getPassword());
//        session.setAttribute("username",user.getUsername());
//        System.out.println(user.getUsername());
//        if (count > 0) {
//            str = "ok";
//        }
//        return str;
//    }
}
